package day5;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Array12 {
    public static void main(String[] args) {
        int[] a = {95, 88, 82, 70, 65, 0};//最后一个0，表示没有值
        Scanner in = new Scanner(System.in);
        System.out.println("请输入要新成绩：");
        int k = in.nextInt();
        //找合适位置,和移动放一起
        int j = a.length - 1 - 1;
        for (; j >= 0; j--) {
            if (a[j] < k) {
                a[j + 1] = a[j];
            } else {
                break;
            }
        }
        a[j + 1] = k;

        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "\t");
        }
        System.out.println();
    }
}
